# coding=utf-8
# knn 第一次测试
from numpy import *
import matplotlib
import matplotlib.pyplot as plt
def createDataSet():
    group=array([
        (1.0,1.1),
        (1.0,1.0),
        (0,0),
        (0,0.1)
    ])
    labels=['A','A','B','B']
    return group,labels

group,labels=createDataSet()
point=[0,0]

plt.figure('name') # 指定图标名称
plt.plot(group[:,0],group[:,1],'.')  # . 代表散点图
plt.plot(0,0,'.')  # . 代表散点图
plt.show()




red= (group-point)**2# 矩阵中每个元素求平方
s = red.sum(axis=1) #axis=1,矩阵每一行相加。axis=0 列相加
sq = s**0.5
distance=sq.argsort()

def compute(point):
    group,labels=createDataSet()
    for i in group:
        for j in i:
            print j
            print i

# compute([1,2])